/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 */

import { TaskNames } from '../common/task-names.js';
import { CompileResource } from '../compile-resource.js';
import { PreviewCompileResource } from '../preview-compile-resource.js';
import { TargetTaskService } from '../service/target-task-service.js';
import { OhosHapTask } from '../task/ohos-hap-task.js';
import CommonTask = TaskNames.CommonTask;

/**
 * 预览时资源编译处理是否支持Restool增量方式编译的hook任务
 *
 * @since 2022/10/12
 */
export class PreviewHookCompileResource extends OhosHapTask {
  constructor(taskService: TargetTaskService) {
    super(taskService, CommonTask.PREVIEW_HOOK_COMPILE_RESOURCE);
  }

  protected doTaskAction(): void {
    // this is a hook task for depends diff task
    // task do nothing
  }

  initTaskDepends(): void {
    // 增量的方式编译 兼容不支持增量编译时，旧的资源编译方式
    this.declareDepends(this.sdkInfo.isPreviewCompileResourceIncrement(this.targetData.isHarmonyOS()) ? PreviewCompileResource.name : CompileResource.name);
  }
}
